#include <iostream>
#include <stdio.h>
using namespace std;

class CA {
    public:
        CA() {
            cout << "Calling CA::CA()" << endl;      
        }
        ~CA() {
            cout << "Calling CA::~CA()" << endl;
        }
};

template <typename T> void show3d(T ppp, int n) {
    int i, j, k;
    cout << "print ppp:" << endl;
    for(i=0; i<n; i++) {
        for(j=0; j<n; j++) {
            for(k=0; k<n; k++) {
                printf("ppp[%d][%d][%d]: %d\n", i, j, k, ppp[i][j][k]);
            }
        }
    } 
}


int main(void)
{
    int i, j, k;
    
    int ***ppp1 = new int**[2];
    
    int ppp2[2][2][2];
    
    typedef int IA[2];
    typedef IA IAA[2];
    IAA *ppp3 = new IAA[2];

    cout << "new CA[2]" << endl;
    CA *ap = new CA[2];
    cout << "delete [] CA*" << endl;
    delete [] ap;
    
    cout << "input for ppp1" << endl;
    for(i=0; i<2; i++) {
        ppp1[i] = new int*[2];
        for(j=0; j<2; j++) {
            ppp1[i][j] = new int[2];
            for(k=0; k<2; k++) {
                cout << "input for ppp1[" 
                     << i 
                     << "][" 
                     << j 
                     << "][" 
                     << k 
                     << "]: ";
                cin >> ppp1[i][j][k];
            }
        } 
    }
    show3d(ppp1, 2);   
    cout << "input for ppp2" << endl;
    for(i=0; i<2; i++) {
        for(j=0; j<2; j++) {
            for(k=0; k<2; k++) {
                cout << "input for ppp2[" 
                     << i 
                     << "][" 
                     << j 
                     << "][" 
                     << k 
                     << "]: ";
                cin >> ppp2[i][j][k];
            }
        } 
    }
    show3d(ppp2, 2);   
    cout << "input for ppp3" << endl;
    for(i=0; i<2; i++) {
        for(j=0; j<2; j++) {
            for(k=0; k<2; k++) {
                cout << "input for ppp3[" 
                     << i 
                     << "][" 
                     << j 
                     << "][" 
                     << k 
                     << "]: ";
                cin >> ppp3[i][j][k];
            }
        } 
    }
    show3d(ppp3, 2);   
    return 0;   
}
